import YZRequest from '../index'

import type { IAccount, ILoginResult } from './types'
import type { IDataType } from '@/network/types'

enum LoginApi {
  AccountLogin = '/login',
  LoginUserInfo = '/users/', // 用法/users/${id}
  UserMenus = '/role/' //用法 role${id}/menu
}

export function accountLoginRequest(account: IAccount) {
  return YZRequest.post<IDataType<ILoginResult>>({
    url: LoginApi.AccountLogin,
    data: account
  })
}

export function requestUserInfoById(id: number | string) {
  return YZRequest.get<IDataType>({
    url: LoginApi.LoginUserInfo + id,
    showLoading: false
  })
}

export function requestUserMenusById(id: number | string) {
  return YZRequest.get<IDataType>({
    url: LoginApi.UserMenus + id + '/menu',
    showLoading: false
  })
}
